package com.project;

/**
 * 匿名内部类
 */
public class MTest {
    public static void main(String[] args) {
        B b = new B();
        b.speak();


        A a = new A(){        //效果等价于class B
            @Override
            public void speak(){
                System.out.println("吱吱叫");
            }
        };
        a.speak();

    }
}

class A{
    public void speak(){
        System.out.println("叫");
    }
}

class B extends A{
    public void speak(){
        System.out.println("汪汪叫");
    }
}
